<?php
/**
 * Created by PhpStorm.
 * User: Shroom Ari
 * Date: 11/20/14
 * Time: 11:24 AM
 */
class Mnews extends MY_Model{
    public $table = 'news';
    function get_news(){
        $this->db->select("*");
        $query = $this->db->get("news");
        return $query->result_array();
    }
    function getNews($perpage,$offset){

        $query = $this->db->get('news',$perpage,$offset);
        return $query->result_array();
    }
    function getNewsById($id){
        $this->db->select('*');
        $this->db->from('news');
        $this->db->where('news_id',$id);
        $this->db->limit(1);
        $query = $this->db->get();
        return $query->result_array();
    }
    function countAll(){
        return $this->db->count_all('news');
    }
    function delete($id){
        $this->db->where('news_id',$id);
        $this->db->delete('news');
    }
    function updateNews($id,$dt){
        $this->db->where('news_id',$id);
        if ($this->db->update('news',$dt))
            return TRUE;
        else return FALSE;
    }
}